package com.rs.portal.reserve.wap;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.jaxplat.commons.Row;
import com.rs.commons.web.PortalBaseAction;
import com.rs.rsbiz.reserve.delegate.ReserveDelegate;
import com.rs.rsbiz.reserve.entity.ReserveOrder;
import com.rs.util.Utils;

public class ReserveAction extends PortalBaseAction
{
    private ReserveDelegate reserveDelegate;

    public ReserveDelegate getReserveDelegate()
    {
        return reserveDelegate;
    }

    public void setReserveDelegate(ReserveDelegate reserveDelegate)
    {
        this.reserveDelegate = reserveDelegate;
    }

    /**
     * 我的预约查询
     * 
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ModelAndView searchSecInfo(HttpServletRequest request, HttpServletResponse response) throws Exception
    {
        Row param = this.parseRequestParametersToRow(request);
        ReserveOrder reserveRecord = new ReserveOrder();
        String orderId = param.getString("resevenmunber");
        String mobileNo = param.getString("phone");
        String returnView = "";
        Map map = new HashMap();
        if (null != orderId && null != mobileNo)
        {
            reserveRecord.setOrderId(orderId);
            reserveRecord.setMobileNo(mobileNo);
            Row reserveInfo = this.reserveDelegate.queryReserve(reserveRecord);
            if (null != reserveInfo)
            {
                String strDate = Utils.myFmtDate(reserveInfo.get("reserve_time").toString());
                map.put("reserveTime", strDate);
                map.put("reserveInfo", reserveInfo); // 这一句相当于request.setAttribute("list",list);
                returnView = "myReserveList"; // 结果页面
            }
            else
            {
                map.put("message", "没有查到该订单记录,请录入正确的订单号和手机号！"); // 返回查询页面
                returnView = "searchMyReserve";
            }
        }
        else
        {
            map.put("message", "订单号和手机号码不能为空！"); // 返回查询页面
            returnView = "searchMyReserve";
        }
        return new ModelAndView(returnView, map);
    }
}
